package org.budo.netty.servlet.server.handler.servlet;

import java.io.IOException;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @author lmw
 */
public class DefaultBudoServletResponse extends AbstractBudoServletResponse {
    private static final Logger log = LoggerFactory.getLogger(DefaultBudoServletResponse.class);

    @Override
    public byte[] getOutputStreamByteArray() {
        try {
            return this.getOutputStream().toByteArray();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    @Override
    public void flushBuffer() throws IOException {
        this.getOutputStream().flush();
    }

    @Override
    public void sendError(int statusCode, String message) throws IOException {
        log.error("#17 sendError, statusCode=" + statusCode + ", message=" + message);
    }

    @Override
    public void sendError(int statusCode) throws IOException {
        this.sendError(statusCode, null);
    }
}